<?php defined('BASEPATH') or die("No access");
    class Status_cart_model extends MY_Model
    {
        public function __construct()
        {
            parent::__construct();
        }
        //get all status_cart
        public function getAll($limit,$offset)
        {
            $this->db->order_by('status_cart.status_cart_id','desc');
            $this->db->limit($limit,$offset);
            $query=$this->db->get('status_cart');
            return $query->result(); 
        }
        //get status_cart by id 
        public function getStatus_cartById($id)
        {
            $this->db->where('status_cart_id',$id);
            $query=$this->db->get('status_cart');
            return $query->row();
        }
        // insert or update 
        public function save($id,$data=array())
        {
            if($id==0)
            {
                //insert new record
                $this->db->insert('status_cart',$data);
            }
            else
            {
                $this->db->where('status_cart_id',$id);
                $this->db->update('status_cart',$data);
            }
            return $this->db->affected_rows();
        }
        //delete array status_carts
        public function delete($id=array())
        {
            $this->db->where_in('status_cart_id',$id);
            $this->db->delete('status_cart');
            return $this->db->affected_rows();
        }
        //publish or unpublish
        public function publish($status,$id=array())
        {
            $this->db->where_in('status_cart_id',$id);
            if($status==0)
            {
                $this->db->update('status_cart',array('status_cart_publish'=>0));
            }
            else
            {
                $this->db->update('status_cart',array('status_cart_publish'=>1));
            }
            return $this->db->affected_rows();
        }
    }
?>

